import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
interface Route {
    String getName();
    String getStartStation();
    String getEndStation();
    List<String> getStations();
    double getDistance();
    double getFare();
    void addStation(String station);
    void removeStation(String station);
    void updateStation(String oldStation, String newStation);
    void queryStations();
}
 abstract class AbstractRoute implements Route {
    protected String name;
    protected List<String> stations;
    public AbstractRoute(String name, List<String> stations) {
        this.name = name;
        this.stations =stations;
    }



     //@Override
    public String getName() {
        return name;
    }
    @Override
    public String getStartStation() {
        return stations.get(0);
    }
    @Override
    public String getEndStation() {
        return stations.get(stations.size() - 1);
    }
    @Override
    public List<String> getStations() {
        return stations;
    }
    //@Override
    public double getDistance() {
        // 计算距离的逻辑
        return 0;
    }
    @Override
    public double getFare() {
        // 计算费用的逻辑
        return 0;
    }
    @Override
    public void addStation(String station) {
        stations.add(station);
    }
    @Override
    public void removeStation(String station) {
        stations.remove(station);
    }
    @Override
    public void updateStation(String oldStation, String newStation) {
        int index = stations.indexOf(oldStation);
        if (index != -1) {
            stations.set(index, newStation);
        }
    }
    @Override
    public void queryStations() {
        System.out.println(getName() + "的站点有：");
        for (String station : stations) {
            System.out.println(station);
        }
    }
}
 class SpecificRoute extends AbstractRoute {
    public String startStation;
    public String endStation;

     public SpecificRoute(String name, List<String> stations, String startStation, String endStation) {
         super(name, stations);
         this.startStation = startStation;
         this.endStation = endStation;
     }

     @Override
    public double getDistance() {
        // 计算距离的逻辑
        return stations.size() * 10;
    }
    @Override
    public double getFare() {
        // 计算费用的逻辑
        return stations.size() * 1;
    }
    @Override
    public void queryStations() {
         System.out.println(getName() + "的站点有：");
        for (String station : stations) {
            System.out.print(station+" ");
        }
        System.out.println();
    }

}
public class TestRouteSystem {
    public static void main(String[] args) {
        Route route = new SpecificRoute("Route 1", new ArrayList<>(Arrays.asList("S1", "S2", "S3", "S4", "S5")),"S1", "S5");

        route.addStation("S6");
        route.removeStation("S2");
        route.queryStations();
        route.updateStation("S3", "S7");
        route.queryStations();
        System.out.println("距离：" + route.getDistance() + "，费用：" + route.getFare());
    }
}

